#ifndef OBJECT_H
#define OBJECT_H

#include "ray.h"
#include "trio.h"
#include "vector3d.h"
#include "transformation.h"
#include "material.h"
#include <vector>

class Object{
    public:
        Object(int = 0, int _type = 0, bool = true);
        Object(const Material &, int = 0, int _type = 0, bool = true);
        Object(const Material &, const Vector3D &, int = 0, int _type = 0, bool = true);
        Object(const Material &, const Vector3D &, int, int, bool, const Matrix &, const Matrix &);
        Object(const Material &, const Vector3D &, int, int, bool, const Transformation &);
        ~Object();

        int getId() const;
        void setId(int);

        const Material &getMaterial() const;
        void setMaterial(const Material &);

        const Vector3D &getCenter() const;
        void setCenter(const Vector3D &);
//
//        void setRelativePosition(const Vector3D &);
//        const Vector3D &getRelativePosition() const {return relativePosition;};

        const Transformation &getTransformation() const {return transformation;};

        bool isSelected() const;
        void select(bool);

        bool isPrimitive() const;
        int getType() const;

        void translate(const Vector3D &);
        void rotate(double, const Vector3D &, const Vector3D & = Vector3D(0,0,0), bool = false);
        void scale(const Vector3D &, const Vector3D & = Vector3D(0,0,0), bool = false);

        virtual double volume() const{return 0;};
        virtual double area() const{return 0;};

        virtual void draw(bool, bool = false, const Material & = Material()) const = 0;
        virtual std::vector<Trio> intersection(const Ray &) const = 0;
        virtual void getMinMax(double *, double *, unsigned int) const = 0;
        virtual Vector3D normal(const Vector3D &) const;

    protected:
        void setBoxPoints(const Vector3D &, const Vector3D &, Vector3D *) const;
        void drawBox(bool, const Vector3D &, const Vector3D &, bool = false, const Material & = Material()) const;

        double toRad(double) const;

        Material chooseMaterial(bool, bool, const Material &) const;

        int id;
        int type;
        bool primitive;
        bool selected;
        Material material;
        Vector3D center;//ponto menos centro
//        Vector3D relativePosition;
        Transformation transformation;

};

#endif
